package j03stream;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Stream;

public class J3 {
    public static void main(String[] args) {
        ArrayList<Integer> arr = new ArrayList<>();
        Collections.addAll(arr,11,33,55,66,55,99,99,88);

//        arr.stream().limit(2).forEach(el-> System.out.println(el));
        arr.stream().distinct().forEach(el-> System.out.println(el));
    }
}

class J4{
    public static void main(String[] args) {
        Set<String> s1 = new HashSet<>();
        Collections.addAll(s1,"aa","rr","hh","kk");

        Stream<String> stream1 = s1.stream();
        stream1.forEach(System.out::println);

        Stream stream2 = Stream.of(4,6,1,8,5,9);
        stream2.forEach(System.out::println);
    }
}

class CarColor{
    //蓝色1，绿色2，黑色3，白色4，黄色5
    //
    public static void main(String[] args) {
        Stream.of(1,2,1,4,5).map(el->{
//            return "绿色";
            switch (el){
                case 1:
                    return "蓝色";
                case 2:
                    return "绿色";
                case 3:
                    return "黑色";
                case 4:
                    return "白色";
                case 5:
                    return "黄色";
            }
            return "未知";
        }).forEach(el-> System.out.println(el));
    }
}
